<!DOCTYPE html>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="utils.js"></script>
<title>Fenced frame content to test pointer lock</title>

<body>
<script>
window.onload = () => {
  requestAnimationFrame(() => {
    simulateGesture(async function() {
      const canvas = document.createElement('canvas');
      document.body.appendChild(canvas);
      const pointer_lock_key = KEYS['pointer-lock'];
      const pointerlockerror_promise = new Promise(resolve => {
        document.addEventListener('pointerlockerror', resolve);
      });
      try {
        await canvas.requestPointerLock();
        writeValueToServer(pointer_lock_key, 'Pointer lock succeeded');
      } catch (e) {
        await pointerlockerror_promise;
        writeValueToServer(pointer_lock_key, 'Pointer lock failed');
      }
      document.exitPointerLock();
    });
  });
};
</script>
</body>
